/*---------------------------------------------------------------------------
Program Name    : MDBManager_bak
Division        : Connection Manager  
Desciprtion     : Single & Multi DBConnection Pool

Create by       : 
Create dt        : 
Modify			  : 
----------------------------------------------------------------------------*/
package com.swit.mobile.db;


import java.sql.*;

import  com.swit.mobile.db.DBManagerException;
import com.swit.mobile.jdf.Config;
import com.swit.mobile.jdf.Configuration;
import com.swit.mobile.servlet.CommonFunction;

public class DBManagerJeus{

private static DBManagerJeus 	instance;
private static Driver 		dbDriver;
private static String 		jdbcLookUpNm;				//jdbc lookup name

/*---------------------------------------------------
		Get JDBC Driver
---------------------------------------------------*/
private DBManagerJeus() throws DBManagerException{

try{
	Config cf = Configuration.getInstance();
				
	jdbcLookUpNm	= cf.get("mobile.pbf.env.jdbc");
	dbDriver 		= (Driver)Class.forName("jeus.jdbc.pool.Driver").newInstance();

}catch(Exception e){
	throw new DBManagerException(e.getMessage());
}		
}

/*---------------------------------------------------
			Get Connection by Pool( Single connection )
---------------------------------------------------*/
public Connection getConnection() throws DBManagerException{
	
	return getConnection(jdbcLookUpNm);
}

public Connection getConnection(String dbName) throws DBManagerException{

Connection      conn    = null;

try{
	conn = dbDriver.connect("jdbc:jeus:pool:"+dbName,null);
}catch(Exception e){ 
	throw new DBManagerException("DBManager.getConnection() : " + e.getMessage());
}


return conn;
}



/*---------------------------------------------------
	Search and make Instance
---------------------------------------------------*/
public static synchronized DBManagerJeus getInstance() throws DBManagerException{
try{
	if( instance == null )	instance = new DBManagerJeus();
}catch(Exception e){
	throw new DBManagerException("DBManager.getInstance() : " + e.getMessage());
}

return instance;
}
}
